package think.in.spring.bean.factory.impl;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import think.in.spring.bean.factory.UserFactory;
import think.in.spring.ioc.overview.domain.User;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

public class UserFactoryImpl implements UserFactory, InitializingBean, DisposableBean {
    @PostConstruct
    public void initByAnnotation() {
        System.out.println("initByAnnotation");
    }
    @Override
    public User createUser() {
        User u =  new User();
        u.setName("UserFactoryImpl");
        return u;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet");
    }

    public void initMethod() {
        System.out.println("initMethod");
    }

    public void destroyMethodByAnnotation() {
        System.out.println("destroyMethodByAnnotation");
    }

    @PreDestroy
    public void destroyMethodByPreDestroy() {
        System.out.println("destroyMethodByPreDestroy");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("destroy");
    }
}
